var t = require;
var e = module;
var o = exports;
Object.defineProperty(o, "__esModule", {value: !0});
o.BezierPart = void 0;
var a = (function () {
    function t(t, e, o, a) {
        this.posArray = [];
        this.lenght = null;
        this.startPos = t;
        this.cPos1 = e;
        this.cPos2 = o;
        this.endPos = a;
        this.lenght = this.getBezierLen();
    }
    t.prototype.createPosArray = function (t) {
        for (var e = Math.floor(this.lenght / t), o = 1 / e, a = o; a <= 1; a += o) {
            var i = this.bezier(this.startPos.x, this.cPos1.x, this.cPos2.x, this.endPos.x, a),
                n = this.bezier(this.startPos.y, this.cPos1.y, this.cPos2.y, this.endPos.y, a);
            this.posArray.push(cc.v2(i, n));
        }
        this.posArray.length < e && this.posArray.push(this.endPos);
    };
    t.prototype.getBezierLen = function (t) {
        void 0 === t && (t = 20);
        var e,
            o,
            a = 0,
            i = cc.v2(0, 0);
        for (e = 0; e <= 1; e += 0.05) {
            var n = this.bezier(this.startPos.x, this.cPos1.x, this.cPos2.x, this.endPos.x, e),
                r = this.bezier(this.startPos.y, this.cPos1.y, this.cPos2.y, this.endPos.y, e);
            a += (o = cc.v2(n, r)).sub(i).mag();
            i = o;
        }
        return a;
    };
    t.prototype.bezier = function (t, e, o, a, i) {
        return t * Math.pow(1 - i, 3) + 3 * e * i * Math.pow(1 - i, 2) + 3 * o * i * i * (1 - i) + a * Math.pow(i, 3);
    };
    return t;
})();
o.BezierPart = a;
var i = new ((function () {
    function t() {
        this.allAbcChar = "abcdefghijklmnopqrstuvwxyz";
        this.abcLen = 3;
        this.dotCount = 2;
        this.addCharCount = 3;
    }
    t.prototype.parseAbc = function (t) {
        for (var e = t.length, o = 0; "0" != t && "0" == t[0]; ) t = t.substring(1, t.length);
        if ("0" == t) return t;
        for (; e > this.abcLen; ) {
            e -= this.addCharCount;
            o++;
        }
        var a = "",
            i = "";
        if (o > 0) {
            for (var n = (i = t.substring(e, e + 2)).length; n >= 0 && "0" == i[--n]; );
            (i = i.substring(0, n + 1)).length > 0 && (i = "." + i);
        }
        for (; o > 0; ) {
            o > this.allAbcChar.length
                ? (a += this.allAbcChar[(Math.floor(o / this.allAbcChar.length) - 1) % this.allAbcChar.length])
                : (a += this.allAbcChar[(o - 1) % this.allAbcChar.length]);
            o -= this.allAbcChar.length;
        }
        return t.substring(0, e) + i + a;
    };
    t.prototype.parseToStr = function (t) {
        var e = Math.abs(Math.floor(t)) + "",
            o = e.length,
            a = "";
        a +=
            o >= 19
                ? e.substring(0, o - 18) + this.getLenValue(e.substring(o - 18, o - 16)) + "AB"
                : o >= 16
                ? e.substring(0, o - 15) + this.getLenValue(e.substring(o - 15, o - 13)) + "AA"
                : o >= 13
                ? e.substring(0, o - 12) + this.getLenValue(e.substring(o - 12, o - 10)) + "T"
                : o >= 10
                ? e.substring(0, o - 9) + this.getLenValue(e.substring(o - 9, o - 7)) + "B"
                : o >= 7
                ? e.substring(0, o - 6) + this.getLenValue(e.substring(o - 6, o - 4)) + "M"
                : o >= 4
                ? e.substring(0, o - 3) + this.getLenValue(e.substring(o - 3, o - 1)) + "K"
                : e;
        return (Math.sign(t) > 0 ? "" : "-") + a;
    };
    t.prototype.getLenValue = function (t) {
        for (var e = "", o = !1, a = t.length - 1; a >= 0; a--) {
            var i = t[a];
            if ("0" != i || o) {
                e = i + e;
                o = !0;
            }
        }
        e.length > 0 && (e = "." + e);
        return e;
    };
    t.prototype.parseBody = function (t, e, o) {
        if (e) {
            var a = e.split("_");
            if (3 == a.length) {
                t[a[0]] || (t[a[0]] = {v: 0, s: o});
                t[a[0]].v += parseInt(a[2]);
            }
        }
    };
    t.prototype.setSortIndex = function (t, e) {
        void 0 === e && (e = 0);
        t.zIndex = 780 - Math.floor(10 * t.y) + e;
    };
    t.prototype.parseBody2 = function (t, e, o) {
        if (o) {
            var a = o.split("_");
            if (3 == a.length) {
                t[a[0]] || (t[a[0]] = 0);
                t[a[0]] += parseInt(a[2]);
                e[a[0]] = a[1];
            }
        }
        return t;
    };
    t.prototype.getFront = function (t) {
        return {Body_Front: t.Body_Front, Eyes: t.Eyes, Face: t.Face, Hand: t.Hand, Tail: t.Tail};
    };
    t.prototype.getBack = function (t) {
        return {Body_Back: t.Body_Back, Tail: t.Tail, Hand: t.Hand};
    };
    t.prototype.getEquitFrontView = function (t, e, o) {
        return {hat: t, wear: e, arms: o};
    };
    t.prototype.getEquitFront = function (t) {
        return {hat: t.hat, wear: t.wear_Front, arms: ""};
    };
    t.prototype.getEquitBack = function (t) {
        return {hat: t.hat, wear: t.wear_Back, arms: ""};
    };
    t.prototype.getAnimalPath = function (t, e) {
        var o = t.curveData.paths[e].props.position,
            a = this.getBezierPartArray(o);
        return this._getPath(a);
    };
    t.prototype._getPath = function (t) {
        for (var e, o = [], a = 0; a < t.length; a++) {
            (e = t[a]).createPosArray(16);
            o = o.concat(e.posArray);
        }
        return o;
    };
    t.prototype.getBezierPartArray = function (t) {
        for (var e = [], o = 0; o < t.length - 1; o++) {
            var a = this.createBezierPartArray(t[o], t[o + 1]);
            e = e.concat(a);
        }
        return e;
    };
    t.prototype.createBezierPartArray = function (t, e) {
        var o,
            i,
            n,
            r,
            s,
            c,
            p = [],
            l = t.motionPath;
        o = cc.v2(t.value[0], t.value[1]);
        c = l[0];
        i = n = cc.v2(c[2], c[3]);
        r = cc.v2(c[0], c[1]);
        p.push(new a(o, i, n, r));
        for (var d = 0; d < l.length - 1; d++) {
            s = l[d];
            c = l[d + 1];
            o = cc.v2(s[0], s[1]);
            i = cc.v2(s[4], s[5]);
            n = cc.v2(c[2], c[3]);
            r = cc.v2(c[0], c[1]);
            p.push(new a(o, i, n, r));
        }
        s = l[l.length - 1];
        o = cc.v2(s[0], s[1]);
        i = n = cc.v2(s[4], s[5]);
        r = cc.v2(e.value[0], e.value[1]);
        p.push(new a(o, i, n, r));
        return p;
    };
    t.prototype.getMinIndex = function (t, e) {
        for (var o = 0, a = 99999, i = 0; i < t.length; i++) {
            var n = t[i].sub(e).mag();
            if (n < a) {
                a = n;
                o = i;
            }
        }
        return o;
    };
    t.prototype.getMinPath = function (t, e, o, a) {
        for (
            var i = this.getMinIndex(e, o), n = this.getMinIndex(e, a), r = Math.sign(n - i), s = e.length;
            i != n && e[i] && s > 0;

        ) {
            s--;
            t.push(e[i]);
            i += r;
        }
        return t;
    };
    t.prototype.copyList = function (t, e, o) {
        void 0 === o && (o = !0);
        if (o) for (var a = 0; a < e.length; a++) t.push(e[a]);
        else for (a = e.length - 1; a >= 0; a--) t.push(e[a]);
        return t;
    };
    t.prototype.parseInTabList = function (t) {
        var e = {};
        for (var o in t) e[o] = this.parseV2List(t[o]);
        return e;
    };
    t.prototype.parseV2List = function (t) {
        for (var e = [], o = 0; o < t.length; o++) e.push(cc.v2(t[o].x, t[o].y));
        return e;
    };
    t.prototype.getListCost = function (t, e) {
        for (var o = "" + t, a = 0; a < e; a++) o += "0";
        return o;
    };
    t.prototype.getSplit = function (t, e) {
        return t ? (t + "").split(e) : [];
    };
    return t;
})())();
window.ParseTool = i;
o.default = i;
